Skip to content

Parallelize test suite to speed up CI - #578

Merged
skarim merged 3 commits into
mainfrom
skarim/test-improvements
Oct 22, 2026
Merged

skarim merged 3 commits into
mainfrom
skarim/test-improvements

Conversation

@skarim

@skarim skarim commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Refactors the tests and adds a dedicated runner to speed up the suite through parallel execution.

Functionality and impact

  • Runs tests in separate processes so Git mocks, environment changes, and working directories do not interfere across workers.
  • Splits Windows and macOS CI into shards while keeping the full suite and race detection on every platform.
  • Reduces repeated fixture setup and preserves existing regression coverage.
  • Reports failures in the affected job and checks that all expected tests ran.

Key areas to review

@skarim
skarim added this pull request to stack #580 October 22, 2026 02:28
@skarim skarim changed the title Speed up cross-platform tests without reducing coverage Speed up cross-platform tests with isolated process shards Oct 22, 2026
@skarim
skarim marked this pull request as ready for review October 22, 2026 14:30
Copilot AI balanced review requested due to automatic review settings October 22, 2026 14:30
@skarim skarim changed the title Speed up cross-platform tests with isolated process shards Parallelize the test suite Oct 22, 2026
@skarim skarim changed the title Parallelize the test suite Parallelize test suite to speed up CI Oct 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The new process-tree cancellation and CI completion checks need final human review backed by successful native-platform runs on Linux, Windows, and macOS.

No open issues 🎉

What changed in this PR

This PR introduces a process-isolated test runner to shorten gh-stack’s cross-platform test suite while retaining race detection and checking test completion.

Changes:

  • Adds test discovery, weighted scheduling, bounded execution, and result verification.
  • Shards Windows and macOS CI and adds a cross-platform completion gate.
  • Streamlines fixtures, restores shared test state, and updates testing documentation.
File Description
scripts/​test/​timings.go Adds advisory scheduling weights for expensive tests.
scripts/​test/​schedule.go Assigns tests to partitions with bounded selectors.
scripts/​test/​report.go Validates results and consistency across shard reports.
scripts/​test/​process_windows.go Adds Windows process-tree cancellation.
scripts/​test/​process_unix.go Adds Unix process-group cancellation.
scripts/​test/​main.go Implements discovery, race-enabled builds, execution, and reporting.
scripts/​test/​main_test.go Tests scheduling, reports, workflow configuration, and process deadlines.
README.md Links to contributor instructions.
internal/​modify/​apply_test.go Splits action tests for scheduling and batches fixture queries.
internal/​git/​rebase_start_test.go Uses a lighter local repository fixture.
internal/​git/​gitops_test.go Streamlines fixtures and enables scoped tests to run in parallel.
CONTRIBUTING.md Documents runner usage, artifacts, and CI verification.
cmd/​view_test.go Restores Git mocks and checks cleanup.
AGENTS.md Updates testing commands and CI guidance.
.github/​workflows/​test.yml Adds shards, artifacts, a completion gate, and stacked-PR triggers.
.github/​copilot-instructions.md Updates runner guidance and test-isolation precautions.

Review effort: Balanced

push:
branches: [main]
pull_request:
branches: [main]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Are we dropping main as a branch argument here to be more permissive so that CI is run for any and all base branches, not solely main anymore? Asking to confirm intent!

On the one hand, I can see this being beneficial for stacked PRs within this repo, like the companion PR to follow this: #579

On the other hand, possibility of increasing compute cost? 😅


docs: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#example-including-branches

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I figured might as well make it more permissive so it runs on all PRs, stacked or not. No particular need for this tbh, but can add the restriction back if CI compute gets out of hand.

Comment thread README.md
| 7 | Rebase already in progress |
| 8 | Stack is locked by another process |

## Contributing

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♥️ We already auto-link in the repository surface since CONTRIBUTING.md is present, but never hurts to be explicit in the README itself

@francisfuzz francisfuzz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved! ✅ This meaningfully reduces the wait for CI. I compared the latest run against the 10 Tests workflow runs immediately before this PR.

Metric Previous median Latest PR run Change
Full workflow 23m 45s 11m 56s 50% shorter
Windows tests 22m 36s 10m 23s 54% shorter
macOS tests 8m 15s 3m 19s 60% shorter
Linux tests 1m 06s 1m 28s 33% longer

Platform test times use the slowest shard.

The two latest revisions both finished in about 12 minutes. The tradeoff is higher aggregate runner usage from parallelizing Windows and macOS, while Linux gets slightly slower. Saving about 12 minutes per CI cycle makes that a worthwhile tradeoff to me.

Comparison details

I used the 10 runs preceding this PR because three of the latest repository runs belong to #579 and already inherit this setup. The baseline includes one failed run. These are observed hosted-runner timings across different commits, not a controlled benchmark.

@skarim
skarim merged commit 082cdac into main Oct 22, 2026
16 checks passed
@skarim
skarim deleted the skarim/test-improvements branch October 22, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants